package org.dreamfly.core.dao.impl;

import org.dreamfly.core.bean.SzActivity;
import org.dreamfly.core.dao.ActivityDAO;
import org.dreamfly.core.util.HTMLInputFilter;
import org.hibernate.Session;
import org.hibernate.Transaction;

/**
 * @author Jhat
 * @date 2010-10-5
 * @time 下午09:38:18
 */
public class ActivityDAOImpl extends BaseDAOImpl<SzActivity,Long> implements ActivityDAO{
 /**/
    @Override
    public void saveInfo(SzActivity activity) {
     HTMLInputFilter inputFilter = new HTMLInputFilter();
		Session session = this.getSession();
		Transaction tx = session.beginTransaction();
		
		SzActivity SzActivity = (SzActivity) session.load(SzActivity.class, activity.getId());
		SzActivity.setTitle(inputFilter.filter(activity.getTitle()));
        SzActivity.setServer(inputFilter.filter(activity.getServer()));
        SzActivity.setNote(inputFilter.filter(activity.getNote()));
		SzActivity.setMinPictureUrl(activity.getMinPictureUrl());
        tx.commit();
		session.flush();
 }

    @Override
    public void modifyInfo(SzActivity activity) {
        HTMLInputFilter inputFilter = new HTMLInputFilter();
		Session session = this.getSession();
		Transaction tx = session.beginTransaction();

		SzActivity SzActivity = (SzActivity) session.load(SzActivity.class, activity.getId());
		SzActivity.setTitle(inputFilter.filter(activity.getTitle()));
        SzActivity.setServer(inputFilter.filter(activity.getServer()));
        SzActivity.setNote(inputFilter.filter(activity.getNote()));
        tx.commit();
		session.flush();
    }
}
